using Commons.Models.Settings.Dtos.Stats;
using Commons.Models.Definitions;
using Commons.Models.Stats;
using Commons.Models.Settings.Mappers.Stats;

namespace Commons.Models.Settings.Mappers
{
	public class LeveledStatMapper : IMapper<LeveledStatDto, LeveledStatDefinition>
	{
		public LeveledStatDefinition Map (LeveledStatDto config)
		{
			LeveledStatDefinition leveledStat = new LeveledStatDefinition(StatUnit.GetByName(config.Name), config.LastLevelLoop);

			LevelMapper mapper = new LevelMapper();
			foreach (LevelDto level in config.Levels)
			{
				leveledStat.AddLevel(mapper.Map(level));
			}

			return leveledStat;
		}
	}
}

